package HashTable;

import java.util.HashSet;
import java.util.Set;

public class _575_DistributeCandies {
    //hint: if candy's kind's number more than candies.length/2,then the sister could have candies.length/2's candies,
    //otherwise, the sister could get the number which equal to the kind's number's candies
    public int distributeCandies(int[] candies) {
        Set<Integer> candySet = new HashSet<Integer>();
        int count = 0;
        for (int i : candies) {
            if (!candySet.contains(i)) {
                candySet.add(i);
                count++;
            }
        }
        return (count>candies.length/2)?candies.length/2:count;
    }
}
